import { toHomeFollow } from "./to/toHomeFollow"
import { httpPost } from "./utils/httpPost"
import { joinAndWaitOpen } from "./utils/joinAndWaitOpen"
import { parseRoomInfo } from "./utils/parseRoomInfo"
import { useStorage } from "./utils/useStorage"


export function taskQb() {
    const storage = useStorage()
    let start = storage.get(`start`, false)
    toHomeFollow()
    while (start) {
        try {
            start = storage.get(`start`, false)
            // 获取连接
            const userId = httpPost('kwai/getKwaiSortJoin', {})
            if (userId) {
                // 打开连接
                app.startActivity({
                    action: "VIEW",
                    data: `kwai://live/play/~${userId}`
                })
                sleep(5000)
                joinAndWaitOpen(userId)
                toHomeFollow()
            } else {
                sleep(1000)
            }
        } catch (e) {

        } finally {
            sleep(random(1000, 2000))
        }
    }
    home();
}